#pragma once
#include "stdlib.h"
#include "stdio.h"
#include "assert.h"
#include "stdbool.h"

typedef int HPDataType;
typedef struct Heap
{
	HPDataType* a;
	int size;
	int capacity;
}Heap;

#define N 8
#define NN 7
#define MM 2

void HeapInit(Heap* hp);
void swap(HPDataType* a, HPDataType* b);
void HeapAdjustDown1(Heap* hp, int j);
void HeapCheck(Heap* hp);
void HeapAdjustDown(Heap* hp);
void HeapAdjustUp(Heap* hp);
void HeapPrint(Heap* hp);
void HeapCreate(Heap* hp, HPDataType* a, int n);
void HeapDestory(Heap* hp);
void HeapPush(Heap* hp, HPDataType x);
void HeapPop(Heap* hp);
HPDataType HeapTop(Heap* hp);
int HeapSize(Heap* hp);
bool HeapEmpty(Heap* hp);

void HeapAdjustDownso(Heap* hp, int j);

void HeapSort(Heap* hp, HPDataType* b, int siz);
void HeapSort1(Heap* hp, HPDataType* b, int siz);
void HeapTopk(Heap* hp, HPDataType* b, int siz, int topk);
void HeapSort2(Heap* hp);